package info;

import java.util.ArrayList;
import java.util.List;

/**
 * The manuscript class is a data object that holds basic information
 * about the manuscript.  Potentially the largest data it can hold is
 * the abstract; the actual manuscript contents are not in the object,
 * but instead a directory is supplied so that the manuscript document
 * can be located.
 * <p>
 * Once the manuscript has progressed into the MSEE review system,
 * additional documents may be found in its associated documents field.
 * Only ID numbers are found, which may be used to locate these
 * documents in the database.
 * 
 * @author Aaron Chen
 * @author James Kantak
 * @author Christopher M. Augg modified to implement Manuscript access in order
 *                             to get only the manuscripts that a user submitted.
 * @version 3/20/2014
 */
public class Manuscript {
  
  /** The value indicating that no decision has been made by the Program Chair. */
  public static final int STATUS_UNDECIDED = 0;
  
  /** The value indicating that the Program Chair has rejected this manuscript. */
  public static final int STATUS_REJECTED = 1;
  
  /** The value indicating that the Program Chair has accepted this manuscript. */
  public static final int STATUS_ACCEPTED = 2;
  
  /** The String representations of the manuscript acceptance statuses. */
  private static final String[] STATUS_STRINGS = {
    "Undecided",
    "Rejected",
    "Accepted"
  };

  
  /** The identification number for this manuscript. */
  private long my_id;
  
  /** The full title of the manuscript. */
  private String my_title;
  
  /** The author that submitted the manuscript. */
  private String my_submitting_author;
  
  /** The submitting author's email address. */
  private String my_email;
  
  /** The name of the conference that the manuscript is being submitted to. */
  private long my_conference_id;
  
  /** The authors that have worked on the manuscript. */
  private List<String> my_authors;
  
  /** The key words that help search engines identify this manuscript. */
  private List<String> my_key_words;
  
  /** The conference categories that this manuscript is submitted under. */
  private List<String> my_categories;
  
  /** The abstract of the manuscript: a summary of the manuscript. */
  private String my_abstract;
  
  /** The directory path that contains the manuscript's full text. */
  private String my_directory_path;
  
  /** The decision status of the manuscript. */
  private int my_decision_status = STATUS_UNDECIDED;
  
  /** The IDs of the authors that have worked on the manuscript. */
  private List<Long> my_author_ids;
  
  /** The IDs of the reviews that reviewers have submitted. */
  private List<Long> my_review_ids = new ArrayList<Long>();
  
  /** The ID of the Subprogram Chair's recommendation form.  There can only be
   * one form at a time. */
  private long my_recommendation_id;
  
    
  /**
   * Creates a manuscript data object.
   * @param the_id              The identification number of the manuscript.
   * @param the_title           The full title of the manuscript.
   * @param the_authors         The list of authors that contributed to the manuscript.
   * @param the_email           The email address of the submitting author.
   * @param the_conference_id      The conference that the manuscript was submitted to.
   * @param the_key_words       The key words that this manuscript is associated with, to help
   *                            search engines find relevant manuscripts.
   * @param the_categories      The conference categories that the manuscript is submitted
   *                            under.
   * @param the_abstract        The summary of the manuscript's contents.
   * @param the_directory_path  The directory path that the original manuscript can be found.
   * @param the_status          The decision status for this manuscript.
   */
  public Manuscript(final long the_id,
                    final String the_title,
                    final List<String> the_authors,
                    final String the_email,
                    final long the_conference_id,
                    final List<String> the_key_words,
                    final List<String> the_categories,
                    final String the_abstract,
                    final String the_directory_path,
                    final int the_status,
                    final List<Long> the_review_ids,
                    final long the_rec_id) {
    my_id = the_id;
    my_title = the_title;
    my_submitting_author = the_authors.get(0);
    my_email = the_email;
    my_conference_id = the_conference_id;
    my_authors = the_authors;
    my_key_words = the_key_words;
    my_categories = the_categories;
    my_abstract = the_abstract;
    my_directory_path = the_directory_path;
    my_decision_status = the_status;
    my_review_ids = the_review_ids;
    my_recommendation_id = the_rec_id;    
  }
  
  /**
   * Appends the review form ID to the manuscript.
   * @param the_id The ID of the review form.
   */
  public void addReviewFormAssociation(final long the_id) {
    my_review_ids.add(the_id);
  }
  
  /**
   * Appends a recommendation form ID to this manuscript.  Any existing recommendation
   * form prior to this call gets replaced.
   * @param the_id The ID of the recommendation form.
   */
  public void addRecommendationAssociation(final long the_id) {
    my_recommendation_id = the_id;
  }
  
  
  /**
   * Returns the identification number of the manuscript.
   * @return The identification number.
   */
  public long getID() {
    return my_id;
  }

  /**
   * Sets the identification number of the manuscript.
   * @param the_id The identification number.
   */
  public void setID(final long the_id) {
    my_id = the_id;
  }
  
  /**
   * Returns the title of the manuscript.
   * @return The title.
   */
  public String getTitle() {
    return my_title;
  }
  /**
   * Returns the author that submitted the manuscript.
   * @return The submitting author.
   */
  public String getSubmittingAuthor() {
    return my_submitting_author;
  }
  /**
   * Returns the email address of the submitting author.
   * @return The email address.
   */
  public String getEmail() {
    return my_email;
  }
  /**
   * Returns the name of the conference that the manuscript was submitted to.
   * @return The conference name.
   */
  public long getConferenceID() {
    return my_conference_id;
  }
  /**
   * Returns the list of authors that worked on the manuscript, including
   * the submitting author.
   * @return The list of authors that worked on the manuscript.
   */
  public List<String> getAuthors() {
    return my_authors;
  }
  /**
   * Returns the list of key words associated with the manuscript.
   * @return The list of key words.
   */
  public List<String> getKeyWords() {
    return my_key_words;
  }
  /**
   * Returns the list of conference categories that the manuscript is submitted under.
   * @return The list of categories.
   */
  public List<String> getCategories() {
    return my_categories;
  }
  /**
   * Returns the abstract of the manuscript.
   * @return The abstract.
   */
  public String getAbstract() {
    return my_abstract;
  }
  /**
   * Returns the directory path where the manuscript can be found.
   * @return The directory path.
   */
  public String getDirectoryPath() {
    return my_directory_path;
  }
  /**
   * Returns the decision status of the manuscript.
   * @return The decision status as an integer.
   */
  public int getDecisionStatus() {
    return my_decision_status;
  }
  /**
   * Returns the decision status of the manuscript as a String.
   * @return The decision status as a String.
   */
  public String getDecisionStatusString() {
    return STATUS_STRINGS[my_decision_status];
  }
  /**
   * Sets the decision status of the manuscript.
   * @param the_status The decision.
   */
  public void setDecisionStatus(final int the_status) {
    my_decision_status = the_status;
  }
  /**
   * Returns the list of IDs of the authors.
   * @return The list of IDs of the authors.
   */
  public List<Long> getAuthorIDs() {
    return my_author_ids;
  }
  /**
   * Returns the list of IDs of associated review forms.
   * @return The list of IDs of associated review forms.
   */
  public List<Long> getReviewIDs() {
    return my_review_ids;
  }
  /**
   * Returns the ID of the associated recommendation form.
   * @return The ID of the associated recommendation form.
   */
  public long getRecommendationID() {
    return my_recommendation_id;
  }
  
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString() { 
    return my_title;
  }
}